//
//  HomePageUserNewsImgViewCollectionViewCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/29.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "HomePageUserNewsImgViewCell.h"
#import "HomePageUserInfoPicView.h"
@interface HomePageUserNewsImgViewCell ()
@property (nonatomic,strong)HomePageUserInfoPicView *picView;
@property (nonatomic,strong)UIImageView *videoImgView;
@property (nonatomic,strong)UIView *coverView;
@property (nonatomic,strong)UIView *titleView;
@property (nonatomic,strong)UILabel *titleLb;
@end

@implementation HomePageUserNewsImgViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    
    self.picView = [[HomePageUserInfoPicView alloc]init];
    [self.contentView addSubview:self.picView];
    
    self.coverView = [[UIView alloc]init];
    self.coverView.backgroundColor = RGBA(0, 0, 0, 0.3);
    [self.contentView addSubview:self.coverView];
    
    self.titleView = [[UIView alloc]init];
    self.titleView.backgroundColor = RGBA(0, 0, 0, 0.5);
    [self.contentView addSubview:self.titleView];
    
    self.titleLb = [[UILabel alloc]init];
    self.titleLb.text = @"审核中";
    self.titleLb.textColor = [UIColor whiteColor];
    self.titleLb.font = font(10);
    [self.titleView addSubview:self.titleLb];
    

    [self.picView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.right.bottom.equalTo(self.contentView);
    }];
    [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
    }];

    self.videoImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"home_thumbnailVideo_tag"]];
    [self.contentView addSubview:self.videoImgView];
    
    [self.videoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.picView);
    }];
    
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(42, 20));
        make.left.top.equalTo(self.contentView);
    }];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.titleView);
    }];
}

- (void)setModel:(HomePageItemModel *)model{
    _model = model;
    if (model.contentType.intValue == 3) {
        if (model.urls.count != 0) {
            [self.picView setIndex:@1 urls:@[model.urls.firstObject]];
        }
    }else{
        [self.picView setIndex:@(MIN(4, model.urls.count)) urls:model.urls];
    }
    
    self.videoImgView.hidden = model.contentType.intValue != 3;

    if ([[RPAppManager getCustomerId] isEqualToNumber:model.userId]) {
        self.titleView.hidden = model.isDisplay.intValue == 1;
    }else{
        self.titleView.hidden = YES;
    }
    
    
}

@end
